package com.android.aishangauction.adapt;

import android.widget.ImageView;
import android.widget.TextView;

import com.android.aishangauction.R;
import com.android.aishangauction.model.member.DirectBuyOrderList;
import com.android.aishangauction.utils.CommonUtils;
import com.android.aishangauction.utils.ObjectUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

public class listMineDirectBuyOrderAdapt extends BaseQuickAdapter<DirectBuyOrderList.DataBean.ListBean, BaseViewHolder> {

    public listMineDirectBuyOrderAdapt(int layoutResId, List<DirectBuyOrderList.DataBean.ListBean> data) {
        super(layoutResId, data);

    }

    @Override
    protected void convert(BaseViewHolder holder, DirectBuyOrderList.DataBean.ListBean data) {
        holder.setText(R.id.item_mineorder_number_tv, "订单号:" + data.getOrder_sn());
        String time = ObjectUtils.getStrTime(data.getC_time(), "yyyy-MM-dd HH:mm:ss");
        holder.setText(R.id.item_mineorder_time, time);
        if(data.getGoods_item()==null || data.getGoods_item().size() == 0)
            return;
        DirectBuyOrderList.DataBean.ListBean.GoodsItemBean goodsItemBean = data.getGoods_item().get(0);
        holder.setText(R.id.item_mineorder_goods_title, goodsItemBean.getName());
        holder.setText(R.id.item_mineorder_goods_num, "x"+goodsItemBean.getBuy_num());
        holder.setText(R.id.item_mineorder_goods_money, "¥" + goodsItemBean.getSell_price());
        holder.setText(R.id.item_mineorder_goods_score, goodsItemBean.getScore_price() + "积分");
        CommonUtils.SetPriceViewHideOrVisible((TextView) holder.getView(R.id.item_mineorder_goods_money), (TextView) holder.getView(R.id.addfuhao),goodsItemBean.getSell_price());


        ObjectUtils.photo(mContext, goodsItemBean.getThumb(), (ImageView) holder.getView(R.id.item_mineorder_goods_img));

        switch (data.getStatus_id()) {
            case 100:
                //待付款
                hideBottom(holder);
                holder.setVisible(R.id.item_list_mine_dingdang_daifukuang_ll, true);
                break;
            case 101:
                //待发货
                hideBottom(holder);
                holder.setVisible(R.id.item_list_mineorder_daifuahuo_ll, true);
                break;
            case 102:
                //待收货
                hideBottom(holder);
                holder.setVisible(R.id.item_list_mine_dingdang_daishouhuo_ll, true);
                break;
            case 110:
                //待评价
                hideBottom(holder);
                if(data.getIs_rate() != null && data.getIs_rate().equals("1")){
                    holder.setVisible(R.id.item_list_mineorder_pinjia_ll, true);
                }else{
                    holder.setVisible(R.id.item_list_mine_dingdang_daipinjia_ll, true);
                }
                break;
            case 111:
                //已取消
                hideBottom(holder);
                holder.setVisible(R.id.item_list_mineorder_cancel_ll, true);
                break;
        }
        holder.addOnClickListener(R.id.daishouhuo_wuliu);
        holder.addOnClickListener(R.id.daishouhuo_queren);
        holder.addOnClickListener(R.id.daifukuang_pay);
        holder.addOnClickListener(R.id.daipinjia_pinjia);
    }

    private void hideBottom(BaseViewHolder holder) {
        holder.setVisible(R.id.item_list_mine_dingdang_daifukuang_ll, false);
        holder.setVisible(R.id.item_list_mine_dingdang_daishouhuo_ll, false);
        holder.setVisible(R.id.item_list_mine_dingdang_daipinjia_ll, false);
        holder.setVisible(R.id.item_list_mineorder_pinjia_ll, false);
        holder.setVisible(R.id.item_list_mineorder_daifuahuo_ll, false);
        holder.setVisible(R.id.item_list_mineorder_cancel_ll, false);
    }

}


